package cn.wbnull.springbootdemo.io;

import java.io.ByteArrayInputStream;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;

import jdk.internal.org.objectweb.asm.tree.VarInsnNode;
import jdk.internal.org.objectweb.asm.tree.analysis.Value;

/**
 * 功能描述
 *
 * @author EDZ
 * @since 2022-09-01
 */
class inputStream {
    public static void main(String[] args) throws IOException {
        byte[] date= { 32,43,108,108,111,12,43,21};
        try (ByteArrayInputStream inputStream = new ByteArrayInputStream(date)){
            String s=readAsString(inputStream);
            System.out.println(s);
        }
    }

    public static String readAsString(InputStream inputStream) throws IOException {
        int n;
        StringBuilder stringBuilder = new StringBuilder();
        while ((n=inputStream.read())!=-1){
            stringBuilder.append((char)n);
        }
        return stringBuilder.toString();
    }
    public void readFile() throws IOException {
        try(FileInputStream inputStream = new FileInputStream("src/readme.txt")) {
            final byte[] bytes = new byte[1000];
            int read;
                 while ((read=inputStream.read()) !=-1){
                System.out.println(read+"  "+bytes);
            }
        }

    }
}
